package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

func main() {
	inputFile, inputErr := os.Open("input.dat")
	if inputErr != nil {
		fmt.Println("打开文件时发生错误\n" +
			"文件是否存在?\n" +
			"是否有权限访问?")
		return
	}
	// 关闭句柄
	defer inputFile.Close()
	inputReader := bufio.NewReader(inputFile)

	ix := 1
	for {
		inputStr, err := inputReader.ReadString('\n')

		fmt.Printf("行%d: %s", ix, inputStr)
		ix++
		if err == io.EOF {
			return
		}
	}
}
